package org.example.codeservce.contr;

import org.example.codeservce.comm.Q;

/**
 * author: Li Qing
 * date: 2024/5/10 11:57
 * description:
 */
public enum CodeFrameworks
{
    SPRING_BOOT("spring-boot", "SPRING_BOOT_BEAN", 1),
    SPRING_CLOUD("spring-cloud", "SPRING_CLOUD_BEAN", 2);

    private String channel;

    private String beanName;

    private Integer type;

    public String getChannel()
    {
        return channel;
    }

    public void setChannel(String channel)
    {
        this.channel = channel;
    }

    public String getBeanName()
    {
        return beanName;
    }

    public void setBeanName(String beanName)
    {
        this.beanName = beanName;
    }

    public Integer getType()
    {
        return type;
    }

    public void setType(Integer type)
    {
        this.type = type;
    }

    CodeFrameworks(String channel, String beanName, Integer type)
    {
        this.channel = channel;
        this.beanName = beanName;
        this.type = type;
    }

    public static CodeFrameworks getChannel(Integer type)
    {
        //通过type找到对应的枚举
        for (CodeFrameworks channel : CodeFrameworks.values())
        {
            if (channel.getType().equals(type))
            {
                return channel;
            }
        }
        throw new IllegalStateException("未找到对应的渠道");
    }
}
